package com.tiancheng.trade.settlement.exception.assertion;

import com.tiancheng.trade.settlement.exception.BusinessException;
import com.tiancheng.trade.settlement.exception.error.IErrorInfo;

import java.text.MessageFormat;

/**
 * 业务异常断言，业务异常错误信息枚举类都实现此接口
 *
 * @author kellen
 * @date 2019-09-03
 */
public interface BusinessExceptionAssert extends IErrorInfo, Assert {

    @Override
    default BusinessException newException(Object... args) {
        String msg = MessageFormat.format(this.getMessage(), args);

        return new BusinessException(this, args, msg);
    }

    @Override
    default BusinessException newException(Throwable t, Object... args) {
        String msg = MessageFormat.format(this.getMessage(), args);

        return new BusinessException(this, args, msg, t);
    }

}
